package com.glory.hikvisionmobile.adapter;

import android.text.TextUtils;
import android.view.Gravity;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.glory.hikvisionmobile.R;
import com.glory.hikvisionmobile.bean.from.MaterielRecordBean;
import com.glory.hikvisionmobile.customView.HikTabView;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_DateUtils;
import com.pda.platform.ui.ui_pdaplatform.utils_public.FreeApi_StringUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * *****************************
 *
 * @Anthor yazhou
 * @Email 1184545990@qq.com
 * @Time 2020/3/24 16:51
 * @DESC *****************************
 */
public class MaterielFromAdapter extends BaseQuickAdapter<MaterielRecordBean, BaseViewHolder> {


    public MaterielFromAdapter(@Nullable List<MaterielRecordBean> data) {
        super(R.layout.item_materiel_from, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MaterielRecordBean item) {
        HikTabView hikTabView = helper.getView(R.id.tabView);
        List<HikTabView.Tab> tabs = new ArrayList<>();
        String time = item.getCreated();
        if (!TextUtils.isEmpty(time)) {
            time = FreeApi_DateUtils.dateToString(FreeApi_DateUtils.stringToDate(item.getCreated(), "yyyy-MM-dd"), "yyyy-MM-dd");
        }
        HikTabView.Tab tab1 = new HikTabView.Tab(time, 1, Gravity.CENTER);
        String workType = "领取";
        if ("T".equals(item.getWorkType())) {
            workType = "退还";
        }
        HikTabView.Tab tab2 = new HikTabView.Tab(workType, 1, Gravity.CENTER);
        HikTabView.Tab tab3 = new HikTabView.Tab(item.getMaterialName(), 1, Gravity.CENTER);
        HikTabView.Tab tab4 = new HikTabView.Tab(TextUtils.isEmpty(item.getMainQty()) ? "0" : item.getMainQty(), 1, Gravity.CENTER);
        HikTabView.Tab tab5 = new HikTabView.Tab(TextUtils.isEmpty(item.getLtQty()) ? "0" : item.getLtQty(), 1, Gravity.CENTER);
        tabs.add(tab1);
        tabs.add(tab2);
        tabs.add(tab3);
        tabs.add(tab4);
        tabs.add(tab5);
        hikTabView.setTabs(tabs);
    }
}
